package com.hsnn.medstgmini.pro.plan.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hsnn.medstgmini.base.std.model.HospInfo;
import com.hsnn.medstgmini.base.std.model.form.StdDrugInfoForm;
import com.hsnn.medstgmini.pro.plan.dao.BidHospplandrugDao;
import com.hsnn.medstgmini.pro.plan.model.BidHospplan;
import com.hsnn.medstgmini.pro.plan.service.BidHospplandrugManager;
import com.hsnn.medstgmini.pro.project.model.BidProjhospital;
import com.hsnn.medstgmini.sys.model.SysPrivilege;
import com.hsnn.medstgmini.util.Pagination;


@Service("bidHospplandrugManager")
public class BidHospplandrugManagerImpl implements BidHospplandrugManager{
	@Autowired
	public BidHospplandrugDao bidHospplandrugDao;

	
	public Pagination getDrugDataList(Pagination page){
		page = bidHospplandrugDao.getDrugDataList(page);
		page = formatProjDrugList(page);
		return page;
	}

	@Transactional
	public void delDrugData(BidHospplan data){
		bidHospplandrugDao.delDrugData(data);
	}
//	@Transactional
//	public void batchAddDrugData(List<BidHospplan> list){
//		bidHospplandrugDao.batchAddDrugData(list);
//	}
	@Transactional
	public void delete(BidHospplan data) {
		bidHospplandrugDao.delete(data);
	}
	@Transactional
	public void batchChangeStatus(List<BidHospplan> list) {
		bidHospplandrugDao.batchChangeStatus(list);
	}
	
	private Pagination formatProjDrugList (Pagination page){
		List<StdDrugInfoForm> flist = new ArrayList<StdDrugInfoForm>();
		List<Object> list = (List<Object>) page.getRows();
		if (null != list && list.size() > 0){
			for (int i = 0; i < list.size(); i++){
				Object[] obj = (Object[]) list.get(i);
				StdDrugInfoForm form = new StdDrugInfoForm();
				form.setProjPlanId(obj[0]==null?"":obj[0].toString());
				form.setDrugCode(obj[1]==null?"":obj[1].toString());
				form.setDrugName(obj[2]==null?"":obj[2].toString());
				form.setFormName(obj[3]==null?"":obj[3].toString());
				form.setSpecName(obj[4]==null?"":obj[4].toString());
				form.setFactor(obj[5]==null?null:obj[5].toString().equals("")?null:Integer.valueOf(obj[5].toString()));
				form.setProdPompName(obj[6]==null?"":obj[6].toString());
				form.setDrugId(obj[7]==null?"":obj[7].toString());
				form.setProjId(obj[8] == null?"":obj[8].toString());
				form.setHospId(page.getConditions().get("hospId")==null?"":page.getConditions().get("hospId"));
				flist.add(form);
			}
		}
		page.setRows(flist);
		return page;
	}

	
	
	
//	@Override
//	public Pagination getInfoBidHospplandrug(Pagination page) {
//		return bidHospplandrugDao.getInfoBidHospplandrug(page);
//		
//	}
//	@Override
//	public void batchSubmitHospTOProj(List<BidHospplan> hospList) {
//		bidHospplandrugDao.batchSubmitHospTOProj(hospList);
//	}








	
	
	
	
	
	
}
